<template>
  <div class="page-box">
    <div class="title-card-box">
      <TitleCard :title="'资金变化'"></TitleCard>
    </div>


    <CustomizeTable :columns="columns" :fetch-data="fetchTableData" permission-prefix="sys:user" :show-selection="true"
      :show-index="false" :export-file-name="'用户'" :init-search-form="{}" @edit="handleEdit" @delete="handleDelete"
      @reset="reset" @status-change="handleStatusChange" ref="table" :showOperation="false" :showKeywordSearch="false">


      <template v-slot:paymentForGoods="{ row }">
        <PublicCell :dataList="[
        {name:'增加',value:row.increase_supply_payment},
        {name:'减少',value:row.reduce_supply_payment},
      ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>


      <template v-slot:ConsumerIntegral="{ row }">
        <PublicCell :dataList="[
        {name:'总和',value:row.total_integral},
        {name:'增加',value:row.increase_integral},
        {name:'减少',value:row.reduce_integral},
        {name:'剩余',value:row.remaining_integral}

      ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>

      <template v-slot:balance="{ row }">
        <PublicCell :dataList="[
       {name:'总和',value:row.total_fund_pool_amount},
       {name:'增加',value:row.fund_pool_increase_amount},
       {name:'减少',value:row.fund_pool_release_amount},
       {name:'剩余',value:row.balance}
      ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>



      <template v-slot:linshiMoney="{ row }">
        <PublicCell :dataList="[
       {name:'增加',value:row.increase_neighbor_bean},
       {name:'减少',value:row.reduce_neighbor_bean},
     ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>

      <template v-slot:ExchangeCertificateCost="{ row }">
        <PublicCell :dataList="[
        {name:'增加',value:row.cost_conversion_amount},
       {name:'减少',value:row.reduce_cost_conversion_amount},
   ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>

      <template v-slot:ExchangeCertificate="{ row }">
        <PublicCell :dataList="[
       {name:'增加',value:row.exchange_products_amount},
       {name:'减少',value:row.reduce_exchange_products_amount},
      ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>

      <template v-slot:Voucher="{ row }">
        <PublicCell :dataList="[
       {name:'增加',value:row.consumption_voucher_amount},
       {name:'减少',value:row.reduce_consumption_voucher_amount},
      ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>

      <template v-slot:RiskControl="{ row }">
        <PublicCell :dataList="[
       {name:'增加',value:row.risk_control_amount},

      ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>

      <template v-slot:offer="{ row }">
        <PublicCell :dataList="[
        {name:'总和',value:row.total_profit_sharing_amount},
      ]" :fontStyle="{ color: '#333' }">
        </PublicCell>
      </template>


























    </CustomizeTable>

    <!-- 审核弹窗 -->
    <el-dialog title="用户信息" :visible.sync="dialogVisible" width="40%">

    </el-dialog>

  </div>
</template>

<script>
  import {

  } from '@/constants/statusMap';

  import {
    toString
  } from "@/utils/tools.js";
  import CustomizeTable from "@/components/CustomizeTable.vue";
  //import ManagerInfoCell from "../components/ManagerInfoCell.vue";
  //import ManagerNumCell from "../components/ManagerNumCell.vue";
  // import RangeInputCard from "@/components/RangeInputCard.vue";
  import PublicCell from "@/components/PublicCell.vue";


  export default {
    components: {

      CustomizeTable,
      // RangeInputCard,

      // ManagerInfoCell,
      // ManagerNumCell,
      PublicCell

    },
    data() {
      return {

        dialogVisible: false,
        currentRow: null,
        columns: [{
            prop: "date",
            label: "日期",
            width: "100px"
          },
          {
            prop: "payment_for_goods",
            label: "供货款",
            slot: "paymentForGoods"
          },

          {
            prop: "ConsumerIntegral",
            label: "新积分",
            slot: "ConsumerIntegral"
          },
          {
            prop: "balance",
            label: "资金池",
            slot: "balance"
          },
          {
            prop: "linshi_money",
            label: "邻事豆",
            slot: "linshiMoney"
          },

          {
            prop: "ExchangeCertificateCost",
            label: "兑换券成本明细",
            slot: "ExchangeCertificateCost",
          },
          {
            prop: "ExchangeCertificate",
            label: "兑换券",
            slot: "ExchangeCertificate",
          },
          {
            prop: "Voucher",
            label: "消费券",
            slot: "Voucher",
          },
          {
            prop: "RiskControl",
            label: "风险调控数值",
            slot: "RiskControl",
          },
          {
            prop: "offer",
            label: "让利金额",
            slot: "offer",
          }
        ],




        searchForm: {


        },
      };
    },
    methods: {
      hangToString(val) {
        return toString(val)
      },
      // 获取表格数据
      async fetchTableData(params = {}) {

        const postData = Object.assign({}, params, this.searchForm);
        if (postData.startTime) {
          postData.start_time = postData.startTime
          postData.end_time = postData.endTime
        }
        try {
          const result = await this.$httpRequest.post('/financialStatements/fundsList', postData)
          console.log('-------fetchTableData----', result)
          return result
        } catch (e) {
          this.$message.error(e.message)
          throw e // 保持错误继续向上传递
        }

      },
      //重置
      reset() {
        this.searchForm.role_id = '';

      },
      // 编辑
      handleEdit(row) {
        // 打开编辑对话框逻辑
        this.currentRow = {
          ...row
        }; // 可深拷贝
        this.dialogVisible = true;
      },

      // 删除
      async handleDelete(row) {
        console.log("删除:", row);
      },

      // 状态变更
      async handleStatusChange(row) {
        console.log("状态变更:", row);
        this.$message.success("状态更新成功");
      },

      handleApprove(payload) {
        console.log("-----状态变更----:", payload);
        this.$httpRequest.post('/user/status', payload).then(result => {
          console.log('--approved---result------', result)
          if (result.code == 0) {
            this.$message.success('完成状态修改')
            this.$refs.table.refresh()
          } else {
            this.$message.error('状态修改失败')
          }
        }).catch(e => {
          this.$message.error(e.message)
        });
      },



    },
  };
</script>

<style>
  .page-box {
    padding: 20px;

  }

  .panbox {
    display: flex;
    justify-content: space-between;
    align-content: center;
    background-color: #fff;
    width: 100%;
    padding: 30px;
    box-sizing: border-box;
    min-height: 200px;
  }

  .panbox-item {
    display: flex;
    align-items: center;
    flex: 1;
    padding: 20px 50px;
    box-sizing: border-box;
    border-radius: 20px;

    position: relative;
    height: 50px;
  }


  .panbox-item-ex {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 20px 50px;
    box-sizing: border-box;
    border-radius: 10px;
    background-color: #fff;
    position: absolute;
    top: 8px;
    left: 0;
    box-shadow: 2px 2px 2px 2px #efefef;
  }


  .pit1-bg {
    background-color: #5772ef;
  }

  .pit2-bg {
    background-color: #4d45cd;
  }

  .pit3-bg {
    background-color: #529bf0;
  }

  .pit4-bg {
    background-color: #55ccf1;
  }



  .pit-1 {
    font-size: 12px;
    color: #999;
  }

  .pit-2 {
    margin-top: 5px;
    font-size: 24px;
    font-weight: 600;
    color: #111;
  }

  .pit-3 {
    margin-top: 5px;
    font-size: 12px;
    color: #008B00;
  }

  .pi-img-box {
    width: 45px;
    height: 45px;
    border-radius: 10px;

    box-sizing: border-box;
    overflow: hidden;
  }


  .p-10 {
    padding: 10px;
  }

  .p-5 {
    padding: 5px;
  }

  .pi-img-box img {
    width: 100%;
    height: 100%;
  }

  .panbox-item-title-box {
    padding-left: 20px;
    box-sizing: border-box;
  }

  .full-fix {
    width: 20px;
    height: 40px;
  }

  .table-box {
    width: 100%;
    margin-top: 20px;
  }

  .search-box {
    display: inline-flex;

    align-items: center;
  }
</style>
